﻿Public Class DonViCungCapDAO
    Public Shared Function DonViCungCap_Load() As DataTable
        Return DataProvider.LoadTable("Select * from DonViCungCap")
    End Function

    Public Shared Sub DonViCungCap_Insert(ByVal dv As DonViCungCapDTO)
        Dim Npara As Integer = 4
        Dim sql As String = "usp_DonViCungCap_InsertDonViCungCap"
        Dim name As String() = New String(Npara - 1) {}
        Dim value As Object() = New Object(Npara - 1) {}
        name(0) = "@MADV"
        name(1) = "@TENDV"
        name(2) = "@SDT"
        name(3) = "@DIACHI"
        dv.Madv = AutoInc.AutoIncStr(DonViCungCapDAO.DonViCungCap_Load, "MADV", "DV")
        value(0) = dv.Madv
        value(1) = dv.Tendv
        value(2) = dv.Sdt
        value(3) = dv.Diachi
        DataProvider.ExecuteNonQueryPara(sql, name, value, Npara)
    End Sub

    Public Shared Sub DonViCungCap_Update(ByVal dv As DonViCungCapDTO)
        Dim Npara As Integer = 4
        Dim sql As String = "usp_DonViCungCap_UpdateDonViCungCap"
        Dim name As String() = New String(Npara - 1) {}
        Dim value As Object() = New Object(Npara - 1) {}
        name(0) = "@MADV"
        name(1) = "@TENDV"
        name(2) = "@SDT"
        name(3) = "@DIACHI"

        value(0) = dv.Madv
        value(1) = dv.Tendv
        value(2) = dv.Sdt
        value(3) = dv.Diachi
        DataProvider.ExecuteNonQueryPara(sql, name, value, Npara)
    End Sub

    Public Shared Sub DonViCungCap_Delete(ByVal dv As DonViCungCapDTO)
        Dim sql As String = String.Format("delete DonViCungCap where MADV = '{0}'", dv.Madv)
        DataProvider.ExecuteNonQuery(sql)
    End Sub
End Class
